package com.example.fragment;



import android.content.Context;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;


import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.fragment.R;

public class LeftFragment extends Fragment {

    Button mButton;

    // 绑定布局文件
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
                // 类似 avtivity 的 setContentView(R.layout.activity_main)方法
        View view = inflater.inflate(R.layout.left_fragment, container, false);
        return view;

    }

    // 在这里面 获取布局中的视图控件
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        mButton = view.findViewById(R.id.button);
        mButton.setOnClickListener(v->{
            Toast.makeText(getContext(), "zwj !!", Toast.LENGTH_LONG).show();
        });
    }
}
